#pragma once
#pragma once
#include"bucket.h"
namespace my_unordered_map
{
	template<class k, class t>
	class unordered_map
	{
		struct mapkeyoft
		{
			const k& operator()(const pair<const k, t>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename Hashtable<k, pair<const k, t>, mapkeyoft>::Iterator Iterator;
		typedef typename Hashtable<k, pair<const k, t>, mapkeyoft>::const_Iterator const_Iterator;
		Iterator begin()
		{
			return _ht.begin();
		}

		Iterator end()
		{
			return _ht.end();
		}

		const_Iterator begin()const
		{
			return _ht.begin();
		}

		const_Iterator end()const
		{
			return _ht.end();
		}

		pair<Iterator, bool> insert(const pair<const k, t>& kv)
		{
			return _ht.insert(kv);
		}

		t& operator[](const k& key)
		{
			pair<Iterator, bool> ret = insert(make_pair(key, t()));
			return ret.first->second;
		}
	private:
		Hashtable<k, pair<const k, t>, mapkeyoft> _ht;
	};
}
